Transfer airpollutants from MAgPIE in coupled mode#2355
Open
dklein-pik wants to merge 11 commits into
Open
Conversation
…rtAirPollutantEmissions
…That means: for SSP2_lowEn scenarios use the landuse data from SSP2 (emissions, supply curves, costs).
Contributor
There was a problem hiding this comment.
Pull request overview
Adds coupling support to pass MAgPIE air pollutant emissions into the REMIND workflow (for reporting), and exposes the land-use emissions baseline switch (cm_LU_emi_scen) in the final GDX for traceability.
Changes:
- Extend
scripts/input/magpie.Rwith air-pollutant variable mappings and export of those emissions to a reporting.cs4rfile alongside the existing GDX coupling export. - Refactor the MAgPIE→REMIND transfer logic by splitting out a
writeToGdx()helper. - Add
cm_LU_emi_scenas a compiler-flag set incore/sets.gmsand adjustscenario_config.csvrows for SSP2_lowEn scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/input/magpie.R | Adds air-pollutant mappings and writes them to a reporting file; refactors GDX writing into a helper. |
| core/sets.gms | Exposes cm_LU_emi_scen as a set in the final GDX. |
| config/scenario_config.csv | Updates SSP2_lowEn scenario rows (but currently changes demand-scenario behavior). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| mappingAP <- tibble::tibble(mag = magAP, enty = remAP, factorMag2Rem = 1, parameter = "AirPollutantsMAgPIE") | ||
|
|
||
| mag2rem <- bind_rows(mag2rem, mappingAP) |
| group_by(period, region, enty, parameter, unit) |> # define groups for summation, include unit to keep it (needed for export of air pollutants to REMIND reporting) | ||
| summarise(value = sum(value), .groups = "drop") |> # sum MAgPIE emissions (variable) that have the same enty in remind | ||
| rename(ttot = period, regi = region) |> # use REMIND set names | ||
| filter(, regi != "World", between(ttot, 2005, 2150)) # keep REMIND time horizon and remove World region |
Comment on lines
+45
to
+49
| # Therefore, they wont be written to the gdx but to an extra file the reporting uses. | ||
| species <- c("BC","CO","NH3","NO2","OC","SO2","VOC") | ||
|
|
||
| magAP <- c(#paste0("Emissions|", species, "|AFOLU|Agriculture"), # exists for BC, CO, OC, SO2 and VOC only (exogenous in MAgPIE) | ||
| paste0("Emissions|", c("NH3", "NO2"), "|Land|+|Agriculture"), # exists for NH3, NO2 only (endogeous in MAgPIE) |
Comment on lines
+40
to
+42
| SSP2_lowEn-NPi2025;0;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;SSP2_lowEn;;;;;;;;;;;;;;;;1;2030;;SSP2-NPi2025;;;SSP2_lowEn-NPi2025: This National Policies Implemented (NPi) scenario follows the Shared Socioeconomic Pathways 2 called Middle of the Road. This scenario also assumes low energy demand trajectories. The NPi reflects currently implemented policies, while fulfilling near-term feasibility and long-term plausibility assessments. Emissions trajectories are aligned with bottom-up studies on the effect of currently implemented policies. Carbon prices are constant in the mid- and long-term. | ||
| SSP2_lowEn-PkBudg650;0;;;;;rcp20;globallyOptimal;;;9;650;;functionalForm;;;100;2055;6;;EUR_regi 0.08, USA_regi 0.07, CHA_regi 0.07, CAZ_regi 0.07, JPN_regi 0.07, GLO 0.06;transformative;;;;;;;;;;2050.GLO 0.9;;;;;;;SSP2_lowEn;;;;;;;2;;;;;;;Elec_Push;Mix4ICEban;1;2030;;SSP2-NPi2025;;;SSP2_lowEn-PkBudg650: This climate policy scenario follows the Shared Socioeconomic Pathways 2 called Middle of the Road. This scenario also assumes low energy demand trajectories. The stylized climate policy scenario assumes a peak budget of 650 Gt CO2 on total CO2 emissions from 2015 to 2100. This is a 1.5C scenario, peak warming is allowed to be at or slightly above 1.5C at median climate sensitivity but returns to values below 1.5C in at least 67 % of scenarios by the end of the century. | ||
| SSP2_lowEn-PkBudg1000;0;;;;;rcp26;globallyOptimal;;;9;1000;;functionalForm;;;75;2080;7;;EUR_regi 0.08, USA_regi 0.07, CHA_regi 0.07, CAZ_regi 0.07, JPN_regi 0.07, GLO 0.06;transformative;;;;;;;;;;2050.GLO 0.5;;;;;;;SSP2_lowEn;;;;;;;2;;;;;;;;Mix3ICEban;1;2030;;SSP2-NPi2025;;;SSP2_lowEn-PkBudg1050: This climate policy scenario follows the Shared Socioeconomic Pathways 2 called Middle of the Road. This scenario also assumes low energy demand trajectories. The stylized climate policy scenario assumes a peak budget of 1050 Gt CO2 on total CO2 emissions from 2015 to 2100. This is a well below 2C scenario at median climate sensitivity but returns to values below 2C in at least 67 % of scenarios during the whole century. |
Contributor
Author
There was a problem hiding this comment.
I didn't change the cm_demScen column, it still contains SSP2_lowEn. I remove SSP2_lowEn from the cm_LU_emi_scen column. Can you check one again, please?
Bugfix to magpie.R. Increase verbosity about appending the MAgPIE report to the REMIND report.
|
|
||
| # Mapping of air pollutant emissions from MAgPIE names to REMIND names | ||
| # Unlike the variables above, the air pollutants are not imported into REMIND GAMS but directly to the reporting. | ||
| # Therefore, they wont be written to the gdx but to an extra file the reporting uses. |
| species <- c("BC","CO","NH3","NO2","OC","SO2","VOC") | ||
|
|
||
| magAP <- c(#paste0("Emissions|", species, "|AFOLU|Agriculture"), # exists for BC, CO, OC, SO2 and VOC only (exogenous in MAgPIE) | ||
| paste0("Emissions|", c("NH3", "NO2"), "|Land|+|Agriculture"), # exists for NH3, NO2 only (endogeous in MAgPIE) |
| quitte::write.mif(tmp_rem_mag, path = remind_reporting_file) | ||
| piamutils::deletePlus(remind_reporting_file, writemif = TRUE) | ||
| } else { | ||
| message("A path to a MAgPIE report was specified but the files cannot be found:", magpie_reporting_file) |
Comment on lines
22
to
+26
| cm_GDPpopScen "cm_GDPpopScen as set for use in GDX" /%cm_GDPpopScen%/ | ||
| cm_APssp "cm_APssp as set for use in GDX" /%cm_APssp%/ | ||
| cm_APscen "cm_APscen as set for use in GDX" /%cm_APscen%/ | ||
| cm_LU_emi_scen "cm_LU_emi_scen as set for use in GDX" /%cm_LU_emi_scen%/ | ||
| cm_rcp_scen "cm_rcp_scen as set for use in GDX" /%cm_rcp_scen%/ |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
Please explain your PR here.
Type of change
Indicate the items relevant for your PR by replacing ◻️ with ☑️.
Do not delete any lines. This makes it easier to understand which areas are affected by your changes and which are not.
Parts concerned
Impact
Checklist
Do not delete any line. Leave unfinished elements unchecked so others know how far along you are.
In the end all checkboxes must be ticked before you can merge.
make test) after my final commit and all tests pass (FAIL 0)remind2if and where it was neededforbiddenColumnNamesin readCheckScenarioConfig.R in case the PR leads to deprecated switchesCHANGELOG.mdcorrectly (added, changed, fixed, removed, input data/calibration)Further information (optional)